package com.jorado.redis;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Redis调用统计
 */
public class RedisInvokeStatistics {
    // redis正常调用次数
    private AtomicLong normalCount = new AtomicLong(0);
    // redis失败调用次数
    private AtomicLong errorCount = new AtomicLong(0);
    // 连接异常次数(连接超时和连接拒绝)
    private AtomicLong connectErrorCount = new AtomicLong(0);
    // 读取超时次数
    private AtomicLong readTimeoutCount = new AtomicLong(0);
    // 执行熔断次数
    private AtomicLong fuseCount = new AtomicLong(0);
    // 执行总时间
    private AtomicLong totalTime = new AtomicLong(0);

    public void incNormalCount() {
        this.normalCount.incrementAndGet();
    }

    public void incErrorCount() {
        this.errorCount.incrementAndGet();
    }

    public void incConnectErrorCount() {
        this.connectErrorCount.incrementAndGet();
    }

    public void incReadTimeoutCount() {
        this.readTimeoutCount.incrementAndGet();
    }

    public void incFuseCount() {
        this.fuseCount.incrementAndGet();
    }

    public void incTotalTime(final long cost) {
        this.totalTime.addAndGet(cost);
    }

    public long getNormalCount() {
        return this.normalCount.get();
    }

    public long getConnectErrorCount() {
        return this.connectErrorCount.get();
    }

    public long getReadTimeoutCount() {
        return this.readTimeoutCount.get();
    }

    public long getTotalTime() {
        return this.totalTime.get();
    }

    public long getFuseCount() {
        return this.fuseCount.get();
    }

    public long getErrorCount() {
        return this.errorCount.get();
    }

}
